import 'package:flutter/material.dart';

class MainPage extends StatelessWidget {
  MainPage({this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new MainPageStatefulWidget(content: title,),
    );
  }
}

class MainPageStatefulWidget extends StatefulWidget {
  MainPageStatefulWidget({Key key, this.content}) : super(key: key);

  final String content;

  @override
  State<StatefulWidget> createState() => MainPageState();
}

class MainPageState extends State<MainPageStatefulWidget> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      body: SafeArea(
        child: Column(
          children: <Widget>[
            Text(widget.content),
            FlatButton(
                textColor: Colors.red,
                child: Text(
                  "返回上一个页面并附带一个值",
                  style: TextStyle(
                    fontSize: 15,
                  ),
                ),onPressed:(){
                  Navigator.pop(context,"第二个页面返回");
            } ,),

          ],
        ),
      ),
    );
  }
}
